﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using _3Dshower;
namespace UnitTestProject1
{
    [TestClass]
    public class TestLine
    {
        double[,][] p = new double[5, 2][]{{new double[2]{0,0},new double[2]{1,1}},
                                        {new double[2]{3,4},new double[2]{7.5,8}},
                                        {new double[2]{10.6,4.5},new double[2]{9.5,6.3}},
                                        {new double[2]{0.1,4},new double[2]{0.1,5}},
                                       {new double[2]{1,6.3},new double[2]{4.5,6.3}}};
        [TestMethod]
        public void Line_test_judge1()
        {
            line lines = new line();
            Point[] lp = new Point[2] { new Point(p[0, 0]), new Point(p[0, 1]) };
            lines.Boundary = lp;
            lines.reCal();
            Assert.AreEqual(lines.judge(new Point(1,3)),direction.UP);
            Assert.AreEqual(lines.judge(new Point(2, 1)), direction.DOWN);
        }
        [TestMethod]
        public void Line_test_judge2()
        {
            line lines = new line();
            Point[] lp = new Point[2] { new Point(p[1, 0]), new Point(p[1, 1]) };
            lines.Boundary = lp;
            lines.reCal();
            Assert.AreEqual(lines.judge(new Point(1, 21d / 9d)), direction.UP);
            Assert.AreEqual(lines.judge(new Point(3, 2)), direction.DOWN);
        }
        [TestMethod]
        public void Line_test_judge3()
        {
            line lines = new line();
            Point[] lp = new Point[2] { new Point(p[2, 0]), new Point(p[2, 1]) };
            lines.Boundary = lp;
            lines.reCal();
            Assert.AreEqual(lines.judge(new Point(0, 23)), direction.UP);
            Assert.AreEqual(lines.judge(new Point(1, 20.2)), direction.DOWN);
        }
        [TestMethod]
        public void Line_test_judge4()
        {
            line lines = new line();
            Point[] lp = new Point[2] { new Point(p[3, 0]), new Point(p[3, 1]) };
            lines.Boundary = lp;
            lines.reCal();
            Assert.AreEqual(lines.judge(new Point(5, 3)), direction.RIGHT);
            Assert.AreEqual(lines.judge(new Point(-3.2, -3)), direction.LEFT);
        }
        [TestMethod]
        public void Line_test_judge5()
        {
            line lines = new line();
            Point[] lp = new Point[2] { new Point(p[4, 0]), new Point(p[4, 1]) };
            lines.Boundary = lp;
            lines.reCal();
            Assert.AreEqual(lines.judge(new Point(4,9)), direction.UP);
            Assert.AreEqual(lines.judge(new Point(6,3.5)), direction.DOWN);
        }


    }
}
